import React from "react";
import routes from "./router";
import {
  createBrowserRouter,
  RouterProvider,
  BrowserRouter,
  Routes,
  Route,
  HashRouter,
  useRoutes,
  Router,
} from "react-router-dom";



// const App = () => {
//   return <RouterProvider router={createBrowserRouter(routes)}></RouterProvider>
// }

// const App = () => {
//   return (
//     // 模式：    hash    history
//     <HashRouter>
//       {/* 单一匹配 */}
//       <Routes>
//         {routes.map((v, i) => {
//           return (
//             <Route path={v.path} element={v.element} key={i}>
//               {v.children &&
//                 v.children.map((item, index) => {
//                   return (
//                     <Route
//                       path={item.path}
//                       element={item.element}
//                       key={index}
//                     ></Route>
//                   );
//                 })}
//             </Route>
//           );
//         })}
//       </Routes>
//     </HashRouter>
//   );
// };


const App = () => {
  const RouterView = () => useRoutes(routes)
  return (<div>
    <BrowserRouter>
      <RouterView></RouterView>
    </BrowserRouter>
  </div>)
}

export default App;
